using UnityEngine;
using System.Collections;

[System.Serializable]
public class LeitorDeCoins
{
	
	public Texture2D[] coinMapsImgs;
	public int[][,] coinMaps = new int[10][,];
	private Texture2D tex;
	private Color tmpColor;
	
	public void Setup ()
	{
		int size = this.coinMapsImgs.Length;
		this.coinMaps = new int[size][,];
		
		for (int i = 0; i < size; i++) {
		
			int[,] tmpCoinMapMatrix;
			
			tex = this.coinMapsImgs [i];
			
			int lines = tex.height;
			int columns = tex.width;
			
			tmpCoinMapMatrix = new int [lines, columns];
				
			for (int x = 0; x < lines; x++) {
				
				for (int y = 0; y < columns; y++) {
				
					tmpColor = tex.GetPixel (y, lines - x);
				
					if (tmpColor.grayscale > 0) {
						
						tmpCoinMapMatrix [x, y] = CoinsMapsManager.NonConditionChar;
					
					} else {

						tmpCoinMapMatrix [x, y] = CoinsMapsManager.ConditionChar;
					}
				}
			}
			
			this.coinMaps [i] = tmpCoinMapMatrix;

		}
	}
	
	public LeitorDeCoins ()
	{
		
	}
	
	public int[,] getCoinMap (int index)
	{
		return this.coinMaps [index];
	}public int[,] getRandomCoinMap()
	{
		int rndCoinMap = Random.Range(0, this.coinMaps.Length);
		
		return this.coinMaps[rndCoinMap];
		
	}
	
}